
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import mhttp from './common/http.js'

Vue.prototype.$api = {
	get:mhttp.myGet,
	post:mhttp.myPost,
	uploadfile:mhttp.uploadfile,
    postURL:mhttp.postURL
};
Vue.prototype.$permission = function(item){
  var userRoles = mhttp.getRoles()
  if(userRoles.includes('super')){
    return true;
  }
  
  if(userRoles.includes(item)){
    return true
  }else{
    return false
  }
}
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
Vue.config.productionTip = false

App.mpType = 'app'

Vue.prototype.$islogin = (path)=>{
    let token = uni.getStorageSync('nangtong_login_token');
  
    if(token){
        return true
    }else{
        return false        
    }
}
Vue.prototype.$navto = (path)=>{
    uni.navigateTo({
        url:path
    })
}
Vue.prototype.$error = (msg)=>{
    uni.showToast({
        title:msg,
        icon:"none",
        duration: 2000
    })
}
Vue.prototype.$success = (msg)=>{
    uni.showToast({
        title:msg,
        icon:"success",
        duration: 2000
    })
}
Vue.prototype.$confirm = (msg)=>{
    return new Promise((resolve, reject)=>{
        uni.showModal({
            content:msg,
            success:function(r){
                if (r.confirm) {
                    resolve()
                } 
            }    
        })
    })
}
const app = new Vue({
    ...App
})
Vue.prototype.$msgNum = ()=>{
    let token = uni.getStorageSync('nangtong_login_token');
    if(token){
        mhttp.myGet(`notice/getNum`).then(({data})=>{
            if(data.count>0){
                uni.setTabBarBadge({
                    index:2,
                    text:""+data.count
                })
            }else{
                uni.removeTabBarBadge({
                    index:2
                })
            }
        })
    }
    
    

}
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif